/**
@description handler文件

@copyright    Copyright 2021 高灯科技
@version      1.0.0
@link         https://www.goldentec.com
@author       venki.chen <venki.chen@goldentec.com>
@datetime     2021/12/8 15:46
*/

package handler

import (
	"context"
	"gitee.com/venki/go_study_accumulate/go_review/20211208/proto/sum"
	"gitee.com/venki/go_study_accumulate/go_review/20211208/sum-srv/service"
)

type handler struct {
}

func (h handler) GetSum(ctx context.Context, req *sum.SumRequest, rsp *sum.SumResponse) error {
	inputs := make([]int64, 0)
	var i int64 = 0
	for ; i <= req.Input; i++ {
		inputs = append(inputs, i)
	}

	rsp.Output = service.GetSum(inputs...)

	return nil
}

func Handler() sum.SumHandler  {
	return handler{}
}
